package org.dtrd.modules.evaluation.entity.bean;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.modules.evaluation.entity.po.DtrdEntEvaluationRdAngiocardiopathy;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author: QR
 * @Date: 2021/9/27-16:37
 */
@ApiModel("心血管10年风险评估量表数据")
@Data
public class AngiocardiopathyInfo {

    private Integer dataId;

    @ApiModelProperty(value = "患者ID")
    private Integer patientId;

    @ApiModelProperty(value = "创建时间")
    private Date createTime;

    @ApiModelProperty(value = "总分")
    private Integer score;

    @ApiModelProperty(value = "绝对危险")
    private Float caseRate;

    @ApiModelProperty(value = "输出内容")
    private String output;

    @ApiModelProperty(value = "手机端输入内容")
    private List<Integer> input;

    public AngiocardiopathyInfo parseFromPo(DtrdEntEvaluationRdAngiocardiopathy po){
        this.setDataId(po.getDataId());
        this.setPatientId(po.getPatientId());
        this.setCreateTime(po.getCreateTime());
        this.setScore(po.getScore());
        this.setCaseRate(po.getCaseRate());
        this.setOutput(po.getOutput());
        String input = po.getInput();
        if (StrUtil.isNotBlank(input)) {
            String[] strings = input.split(",");
            ArrayList<Integer> list = new ArrayList<>(strings.length);
            for (String s : strings) {
                list.add(Integer.parseInt(s));
            }
            this.setInput(list);
        }
        return this;
    }
}
